x86/svm: Fixes to OS Visible Workaround handling
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 27 Feb 2018 17:22:40 +0000 (17:22 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 28 Aug 2018 10:37:11 +0000 (11:37 +0100)
commitc416666181684a28d9f11989b8b7ef4dfe2ab78b
treea7973f3c2f027184c70c8d88169baee607771c38
parent6ffa33b370f58ed937806105921f66c83aed45e0
x86/svm: Fixes to OS Visible Workaround handling

OSVW data is technically per-cpu, but it is the firmwares reponsibility to
make it equivelent on each cpu.  A guests OSVW data is sourced from global
data in Xen, clearly making it per-domain data rather than per-vcpu data.

Move the data from struct arch_svm_struct to struct svm_domain, and call
svm_guest_osvw_init() from svm_domain_initialise() instead of
svm_vcpu_initialise().

In svm_guest_osvw_init(), reading osvw_length and osvw_status must be done
under the osvw_lock to avoid observing mismatched values.  The guests view of
osvw_length also needs clipping at 64 as we only offer one status register (To
date, 5 is the maximum index defined AFAICT).  Avoid opencoding max().

Drop svm_handle_osvw() as it is shorter and simpler to implement the
functionality inline in svm_msr_{read,write}_intercept().  As the OSVW MSRs
are a contiguous block, we can access them as an array for simplicity.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
xen/arch/x86/hvm/svm/svm.c
xen/include/asm-x86/hvm/svm/vmcb.h